A large volume of image data handled in an electronic camera or a computer normally undergo image compression (e.g., JPEG compression) processing. The image compression processing may be executed through, for instance, the following steps 1–6.
1. The electronic camera determines a target image data compression rate (target code volume) in correspondence to the compressed image quality setting selected by the photographer (e.g., by switching to one of; FINE/NORMAL/BASIC).
2. The electronic camera divides the image data constituted of the brightness Y and the color differences Cb, Cr into blocks each made up of, for instance, 8×8 pixels. The electronic camera then implements DCT (discrete cosine transform) in units of the individual blocks resulting from the division and obtains transformation coefficients each corresponding to one of 8×8 discrete spatial frequencies.
3. The electronic camera prepares a reference quantization table defining a quantization step in correspondence to each of the 8×8 transformation coefficients. By multiplying data in the reference quantization table by a scale factor SF (a type of compression parameter), the electronic camera obtains a quantization table to be utilized in actual processing.
4. The electronic camera quantizes each of the 8×8 transformation coefficients using the quantization table obtained in step 3.
5. The electronic camera encodes the DC component in the quantized data in order to eliminate any redundancy while allowing for an estimated difference relative to the immediately preceding block. In addition, it implements zigzag scanning on the AC component in the quantized data and then encodes the AC component in order to eliminate any redundancy.
6. If the size of the compressed file (hereafter referred to as the “compression size”) deviates from the allowable target code volume range, the electronic camera first readjusts the value of the scale factor SF and then re-engages in the operation in step 3 above. If, on the other hand, the compression size is within the allowable target code volume range (normally set to; target code volume±allowable error), it ends the image compression processing.
Through the processing described above, the image data can be compressed at a compression rate within the allowable target compression rate range.
If the allowable target code volume range is set to a fixed range such as target code volume±allowable error as explained above, the compression code volume fluctuates within the allowable range. As a result, when the compressed data having undergone the image compression processing are sequentially recorded at a storage medium, there will be a significant unused area remaining on the storage medium, i.e., an area the size of which is not large enough to record the compression code volume corresponding to a single frame (hereafter referred to as a “remaining area”). While the size of the remaining area changes as of the photographing/recording operation advances due to the inconsistency in the compression code volume mentioned earlier, the average compression code volume is highly likely to be roughly equal to the target code volume. Accordingly the remaining area does not manifest the tendency for either a steady increase or a steady decrease as the photographing/recording operation progresses.
In addition, the capacity of the storage medium is not always set at an integral multiple of the target code volume.
For the reasons stated above, a remaining area the size of which cannot be disregarded is often left on the storage medium. From the viewpoint of preventing any image quality loss during the image compression, it is desirable to maximize the compression code volume per frame so as to leave as little remaining area as possible.